/**
 * Company : Thai Informatic System Co., Ltd.
 * Created By : Dr.Tree
 * Created On : Mar 12, 2012  11:36:55 AM 
 * e-Mail : chatree@tis.co.th
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : jpa.service.promis.construction
 * File Name : VwSyncGrnItemServices.java
 * TODO
 */
package jpa.service.promis.construction;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import org.apache.log4j.Logger;
import promis.utility.CommonService;
import jpa.entitys.promis.construction.SyncPr;
import jpa.entitys.promis.construction.VwSyncGrnItem;
import jpa.service.common.JPAService;

/**
 * @author chatree
 *
 */
public class VwSyncGrnItemServices extends JPAService {
	
	private static final Logger log = Logger.getLogger(VwSyncGrnItemServices.class);

	/**
	 * @param em
	 */
	public VwSyncGrnItemServices(EntityManager em) {
		super(em);
		// TODO Auto-generated constructor stub
	}
	
	
	public SyncPr findById(String id) throws Exception {		
	
		return super.ConvertToYoureObject(super.find(id, "VwSyncGrnItem.findById"));				
	}
	
	public List<SyncPr> findAll() throws Exception {
		return super.ConvertToYoureObject(super.findAll("VwSyncGrnItem.findAll"));
	}
	
	public List<VwSyncGrnItem> findByDocumentNo(String company, String project ,String documentNo, String status, String syncIsstaging) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("project", project);
		mapWhereValue.put("documentNo", documentNo);
		mapWhereValue.put("status", status);
		mapWhereValue.put("syncIsstaging", syncIsstaging);
		
		return super.ConvertToYoureObject(super.find("VwSyncGrnItem.findByDocumentNo", mapWhereValue));
	}
	
	public List<VwSyncGrnItem> findByDocumentNoWithoutSyncIsstaging(String company, String project ,String documentNo, String status) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("project", project);
		mapWhereValue.put("documentNo", documentNo);
		mapWhereValue.put("status", status);
		
		return super.ConvertToYoureObject(super.find("VwSyncGrnItem.findByDocumentNo1", mapWhereValue));
	}
	
	public List<VwSyncGrnItem> findByDocumentItemByUnit(String company, String project ,String documentNo, String unitNumber, String status) throws Exception {
		Map<String,Object> mapWhereValue = new HashMap<String, Object>();				
		mapWhereValue.put("company", company);
		mapWhereValue.put("project", project);
		mapWhereValue.put("documentNo", documentNo);
		mapWhereValue.put("unitNumber", unitNumber);
		mapWhereValue.put("status", status);
		
		return super.ConvertToYoureObject(super.find("VwSyncGrnItem.findByDocumentItemByUnit", mapWhereValue));
	}
	

}
